//
//  UILabel+Extension.swift
//  MPSinaWeibo
//
//  Created by DaVinci on 16/4/13.
//  Copyright © 2016年 DaVinci. All rights reserved.
//

import UIKit


extension UILabel {

    convenience init(text: String,textColor: UIColor,fontSize: CGFloat,margin: CGFloat = 0) {
    
       self.init()
       
       self.text = text
       self.textColor = textColor
        
        font = UIFont.systemFontOfSize(fontSize)
        numberOfLines = 0
        //设置居中
        textAlignment = .Left
        //设置 最大显示的宽度
        //        l.preferredMaxLayoutWidth = 230
        //自适应大小
        if margin > 0{
        
           preferredMaxLayoutWidth = ScreenWidth - 2 * margin
        }
        
        sizeToFit()

    }

}